﻿import logging

logging.basicConfig(filename='myapp.log',
                    level=logging.INFO,
                    format="%(message)s")

# 定义一个Handler打印INFO及以上级别的日志到sys.stderr  
console = logging.StreamHandler()  
console.setLevel(logging.INFO)  
# 设置日志打印格式  
formatter = logging.Formatter('%(message)s')  
console.setFormatter(formatter)  
# 将定义好的console日志handler添加到root logger  
logging.getLogger('').addHandler(console)

log = logging.getLogger(__file__)

log.info('haha')

raw_input('')
